<@master template="/common/master"  title="首页-p2p金融">
    <@include file="/common/head"/>
  	<@head title="实名验证" dColor="dlHeader"/>
    <form id="subForm" role="form" class="form-horizontal action-ajax-form" action="/member/submit/nameVerify">
    <div class="dlBox">
    	<p id="errorText" class="wrong">${errorMsg}</p>
        <ul class="dllist">
        	<li><span class="yhIco icon"></span><input name="realName" type="text" placeholder="请输入你的真实姓名"></li>
            <li><span class="sfzIco icon"></span><input name="idCardNo" type="text" placeholder="输入你的身份证号码"></li>
            <li><span class="sfzIco icon"></span><input name="bankNo" type="text" placeholder="输入你的银行卡号"></li>
        </ul>
    </div>
    <div class="btnBox">
    	<input id="subBtn" type="button" value="立即验证"  class="tzBtn"/>
        <p class="c999 tac mt10">为保障您的资金安全，认证后只能绑定与实名为同一个人的银行卡</p>
    </div>
    </form>
    <div id="showMsgDiv" class="bodyBg" style="display:none;">
	    <div class="tsTxt">
		   	<div class="tcTxt b_b"><strong>请输入短信验证码完成绑卡</strong></div>
		   	<p class="tac c999 lh60"><span id="errorPupText" class="red">${errorMsg}</span></p>
		    <div class="mlr20">
		    	<input  id="validatecode" type="text" class="tcInp" placeholder="请输入六位短信验证码"><a id="againBtn" href="#" class="yzmTxt">重新获取</a>
		    </div>
		    <div class="b_t mt20 tcSure">
		    	<a id="confirmBtn" href="#">确定</a><a id="cancelBtn" href="#" class="blue">取消</a>
		    </div>
	    </div>
	</div>
    <div id="loadingDiv" class="bodyBg" style="display:none;">
    	<div class="gifTxt"><@img src="/images/p2p/gif1.gif"/></div>
    </div>
</@master>
<@js src="/js/p2p/investor/validate.js"/><@jsRender/>
<@js>
    $(document).ready(function(){
    	$('#subBtn').bind("click",function(){
    		var realName=$('#subForm input[name="realName"]').val();
    		if(!realName){
    			$('#errorText').text('真实姓名不能为空');
    			return false;
    		}
    		var idCardNo=$('#subForm input[name="idCardNo"]').val();
    		if(!idCardNo){
    			$('#errorText').text('身份证号码不能为空');
    			return false;
    		}
    		var bankNo=$('#subForm input[name="bankNo"]').val();
    		if(!bankNo){
    			$('#errorText').text('银行卡号码不能为空');
    			return false;
    		}
    		var idCardNoResult=$.fn.validate.idCard(idCardNo);
    		if(!idCardNoResult.isSuccess){
    			$('#errorText').text(idCardNoResult.errorMsg);
    			return false;
    		}
    		$('#loadingDiv').show();
    		$.ajax({
                    type: 'POST',
                    data:$("#subForm").serialize(),
                    url: '/member/rest/ajaxBindCard',
                    success: function(result){
                    	$('#loadingDiv').hide();
	                    if(result.action == "error"){
	                    	$('#errorText').text(result.message);
	    					return false;
	                    }
	                    $('#showMsgDiv').show();
                    }
                });
    	});
    	$('#cancelBtn').bind("click",function(){
    		$('#showMsgDiv').hide();
    		$('#errorPupText').text('');
    	});
    	$('#confirmBtn').bind("click",function(){
    		var validatecode=$('#validatecode').val();
    		if(!validatecode){
    			$('#errorPupText').text('短信验证码不能为空');
    			return false;
    		}
    		$('#loadingDiv').show();
    		$.ajax({
                    type: 'POST',
                    data:{'validatecode':validatecode},
                    url: '/member/rest/ajaxBindCardConfirm',
                    success: function(result){
	                    if(result.action == "error"){
	                   		$('#loadingDiv').hide();
	                    	$('#errorPupText').text(result.message);
	    					return false;
	                    }
	                    $('#subForm').submit();
                    }
                });
    		
    	});
    	$('#againBtn').bind("click",function(){
    		$('#errorPupText').text('');
    		$.ajax({
                    type: 'POST',
                    url: '/member/rest/ajaxBindCardResendsms',
                    success: function(result){
	                    if(result.action == "error"){
	                    	$('#errorPupText').text(result.message);
	    					return false;
	                    }
                    }
                });
    	});
	});
</@js>
<@jsRender/>
